package com.woniuxy.config.rabbitmq;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @Author: 马宇航
 * @Description: 配置路由模式
 * @DateTime: 25/10/27/星期一 12:03
 * @Component: 成都蜗牛学苑
 **/
@Configuration
public class RouteModelConfig {
    //待支付队列
    @Bean
    public Queue routePendingPaymentQueue(){
        return new Queue("routePendingPayment");
    }
    //已支付队列
    @Bean
    public Queue routePaymentedQueue(){
        return new Queue("routePaymentedQueue");
    }
    //创建交换机 租车 rentalCarPayExchange 和支付相关的
    @Bean
    public Exchange routePayExchange(){
        return new DirectExchange("rentalCarPayExchange");
    }
    //绑定 交换机和队列 待支付
    @Bean
    public Binding noPayRouting(){
        return BindingBuilder.bind(routePendingPaymentQueue())
                .to(routePayExchange())
                .with("noPay").noargs();
    }
    //绑定 交换机和队列 已支付
    @Bean
    public Binding payedRouting(){
        return BindingBuilder.bind(routePaymentedQueue())
                .to(routePayExchange())
                .with("payed").noargs();
    }
    @Bean
    public Binding payedRouting2(){
        return BindingBuilder.bind(routePaymentedQueue())
                .to(routePayExchange())
                .with("paying").noargs();
    }
}
